#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

void my_strcpy(char* res, char* dest, const size_t m)
{
    while ((*dest++ = *(res++ + m - 1)));
}

int main() {
    char arr_res[30] = { 0 };
    char arr_dst[30] = { 0 };
    int m = 0;
    scanf("%s", arr_res);
    scanf("%d", &m);
    my_strcpy(arr_res, arr_dst, m);
    printf("%s\n", arr_dst);
    return 0;
}